package two;

import java.util.Arrays;

public class ArrayTraverseAndCopy {
    public static void main(String[] args) {
        int[] a = {1, 2, 3, 4, 500, 600, 700, 800};
        System.out.println(Arrays.toString(a));
        //将a的全部元素复制到其他数组中，并打印
        int[] b = Arrays.copyOf(a, a.length);
        System.out.println(Arrays.toString(b));
        // 复制部分元素，并打印
        int[] c = Arrays.copyOfRange(a, 0, 4);
        int[] d = Arrays.copyOfRange(a, 4, 8);
        System.out.println(Arrays.toString(c));
        System.out.println(Arrays.toString(d));
        //改变b数组的元素的值
        b[4] = 521;
        //再输出数组a的全部元素
        System.out.println(Arrays.toString(a));
    }
}
